Optimal. Leaf size=152 \[ \frac {\left (a^4+6 a^2 b^2-3 b^4\right ) x}{2 \left (a^2+b^2\right )^3}+\frac {4 a b^3 \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right )^3 d}+\frac {b \left (a^2-3 b^2\right )}{2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))}+\frac {\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.12, antiderivative size = 152, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 6, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3587, 755, 815,
649, 209, 266} \begin {gather*} \frac {b \left (a^2-3 b^2\right )}{2 d \left (a^2+b^2\right )^2 (a+b \tan (c+d x))}+\frac {\cos ^2(c+d x) (a \tan (c+d x)+b)}{2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}+\frac {4 a b^3 \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^3}+\frac {x \left (a^4+6 a^2 b^2-3 b^4\right )}{2 \left (a^2+b^2\right )^3} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 209
Rule 266
Rule 649
Rule 755
Rule 815
Rule 3587
Rubi steps
\begin {align*} \int \frac {\cos ^2(c+d x)}{(a+b \tan (c+d x))^2} \, dx &=\frac {\text {Subst}\left (\int \frac {1}{(a+x)^2 \left (1+\frac {x^2}{b^2}\right )^2} \, dx,x,b \tan (c+d x)\right )}{b d}\\ &=\frac {\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}-\frac {b \text {Subst}\left (\int \frac {-3-\frac {a^2}{b^2}-\frac {2 a x}{b^2}}{(a+x)^2 \left (1+\frac {x^2}{b^2}\right )} \, dx,x,b \tan (c+d x)\right )}{2 \left (a^2+b^2\right ) d}\\ &=\frac {\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}-\frac {b \text {Subst}\left (\int \left (\frac {a^2-3 b^2}{\left (a^2+b^2\right ) (a+x)^2}-\frac {8 a b^2}{\left (a^2+b^2\right )^2 (a+x)}+\frac {-a^4-6 a^2 b^2+3 b^4+8 a b^2 x}{\left (a^2+b^2\right )^2 \left (b^2+x^2\right )}\right ) \, dx,x,b \tan (c+d x)\right )}{2 \left (a^2+b^2\right ) d}\\ &=\frac {4 a b^3 \log (a+b \tan (c+d x))}{\left (a^2+b^2\right )^3 d}+\frac {b \left (a^2-3 b^2\right )}{2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))}+\frac {\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}-\frac {b \text {Subst}\left (\int \frac {-a^4-6 a^2 b^2+3 b^4+8 a b^2 x}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{2 \left (a^2+b^2\right )^3 d}\\ &=\frac {4 a b^3 \log (a+b \tan (c+d x))}{\left (a^2+b^2\right )^3 d}+\frac {b \left (a^2-3 b^2\right )}{2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))}+\frac {\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}-\frac {\left (4 a b^3\right ) \text {Subst}\left (\int \frac {x}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{\left (a^2+b^2\right )^3 d}+\frac {\left (b \left (a^4+6 a^2 b^2-3 b^4\right )\right ) \text {Subst}\left (\int \frac {1}{b^2+x^2} \, dx,x,b \tan (c+d x)\right )}{2 \left (a^2+b^2\right )^3 d}\\ &=\frac {\left (a^4+6 a^2 b^2-3 b^4\right ) x}{2 \left (a^2+b^2\right )^3}+\frac {4 a b^3 \log (\cos (c+d x))}{\left (a^2+b^2\right )^3 d}+\frac {4 a b^3 \log (a+b \tan (c+d x))}{\left (a^2+b^2\right )^3 d}+\frac {b \left (a^2-3 b^2\right )}{2 \left (a^2+b^2\right )^2 d (a+b \tan (c+d x))}+\frac {\cos ^2(c+d x) (b+a \tan (c+d x))}{2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 4.21, size = 304, normalized size = 2.00 \begin {gather*} \frac {-\frac {a b \left (\left (-a+\sqrt {-b^2}\right ) \log \left (\sqrt {-b^2}-b \tan (c+d x)\right )-2 \sqrt {-b^2} \log (a+b \tan (c+d x))+\left (a+\sqrt {-b^2}\right ) \log \left (\sqrt {-b^2}+b \tan (c+d x)\right )\right )}{\sqrt {-b^2} \left (a^2+b^2\right )}+\frac {\cos ^2(c+d x) (b+a \tan (c+d x))}{a+b \tan (c+d x)}+\frac {b \left (a^2-3 b^2\right ) \left (\left (2 a+\frac {-a^2+b^2}{\sqrt {-b^2}}\right ) \log \left (\sqrt {-b^2}-b \tan (c+d x)\right )-4 a \log (a+b \tan (c+d x))+\left (2 a+\frac {a^2-b^2}{\sqrt {-b^2}}\right ) \log \left (\sqrt {-b^2}+b \tan (c+d x)\right )+\frac {2 \left (a^2+b^2\right )}{a+b \tan (c+d x)}\right )}{2 \left (a^2+b^2\right )^2}}{2 \left (a^2+b^2\right ) d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.42, size = 154, normalized size = 1.01
method | result | size |
derivativedivides | \(\frac {-\frac {b^{3}}{\left (a^{2}+b^{2}\right )^{2} \left (a +b \tan \left (d x +c \right )\right )}+\frac {4 b^{3} a \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{3}}+\frac {\frac {\left (\frac {a^{4}}{2}-\frac {b^{4}}{2}\right ) \tan \left (d x +c \right )+a^{3} b +a \,b^{3}}{1+\tan ^{2}\left (d x +c \right )}-2 a \,b^{3} \ln \left (1+\tan ^{2}\left (d x +c \right )\right )+\frac {\left (a^{4}+6 a^{2} b^{2}-3 b^{4}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{2}}{\left (a^{2}+b^{2}\right )^{3}}}{d}\) | \(154\) |
default | \(\frac {-\frac {b^{3}}{\left (a^{2}+b^{2}\right )^{2} \left (a +b \tan \left (d x +c \right )\right )}+\frac {4 b^{3} a \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{3}}+\frac {\frac {\left (\frac {a^{4}}{2}-\frac {b^{4}}{2}\right ) \tan \left (d x +c \right )+a^{3} b +a \,b^{3}}{1+\tan ^{2}\left (d x +c \right )}-2 a \,b^{3} \ln \left (1+\tan ^{2}\left (d x +c \right )\right )+\frac {\left (a^{4}+6 a^{2} b^{2}-3 b^{4}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{2}}{\left (a^{2}+b^{2}\right )^{3}}}{d}\) | \(154\) |
risch | \(\frac {3 i x b}{6 i b \,a^{2}-2 i b^{3}-2 a^{3}+6 b^{2} a}-\frac {x a}{6 i b \,a^{2}-2 i b^{3}-2 a^{3}+6 b^{2} a}-\frac {i {\mathrm e}^{2 i \left (d x +c \right )}}{8 \left (-2 i a b +a^{2}-b^{2}\right ) d}+\frac {i {\mathrm e}^{-2 i \left (d x +c \right )}}{8 \left (2 i a b +a^{2}-b^{2}\right ) d}-\frac {8 i a \,b^{3} x}{a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}}-\frac {8 i a \,b^{3} c}{d \left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right )}-\frac {2 i b^{4}}{\left (-i a +b \right )^{2} d \left (i a +b \right )^{3} \left (b \,{\mathrm e}^{2 i \left (d x +c \right )}+i a \,{\mathrm e}^{2 i \left (d x +c \right )}-b +i a \right )}+\frac {4 a \,b^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right )}{d \left (a^{6}+3 a^{4} b^{2}+3 a^{2} b^{4}+b^{6}\right )}\) | \(318\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.50, size = 282, normalized size = 1.86 \begin {gather*} \frac {\frac {8 \, a b^{3} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{6} + 3 \, a^{4} b^{2} + 3 \, a^{2} b^{4} + b^{6}} - \frac {4 \, a b^{3} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{6} + 3 \, a^{4} b^{2} + 3 \, a^{2} b^{4} + b^{6}} + \frac {{\left (a^{4} + 6 \, a^{2} b^{2} - 3 \, b^{4}\right )} {\left (d x + c\right )}}{a^{6} + 3 \, a^{4} b^{2} + 3 \, a^{2} b^{4} + b^{6}} + \frac {2 \, a^{2} b - 2 \, b^{3} + {\left (a^{2} b - 3 \, b^{3}\right )} \tan \left (d x + c\right )^{2} + {\left (a^{3} + a b^{2}\right )} \tan \left (d x + c\right )}{a^{5} + 2 \, a^{3} b^{2} + a b^{4} + {\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} \tan \left (d x + c\right )^{3} + {\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} \tan \left (d x + c\right )^{2} + {\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} \tan \left (d x + c\right )}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.43, size = 279, normalized size = 1.84 \begin {gather*} \frac {{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} \cos \left (d x + c\right )^{3} - {\left (a^{2} b^{3} + 3 \, b^{5} - {\left (a^{5} + 6 \, a^{3} b^{2} - 3 \, a b^{4}\right )} d x\right )} \cos \left (d x + c\right ) + 4 \, {\left (a^{2} b^{3} \cos \left (d x + c\right ) + a b^{4} \sin \left (d x + c\right )\right )} \log \left (2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + b^{2}\right ) - {\left (a^{3} b^{2} - a b^{4} - {\left (a^{4} b + 6 \, a^{2} b^{3} - 3 \, b^{5}\right )} d x - {\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} \cos \left (d x + c\right )^{2}\right )} \sin \left (d x + c\right )}{2 \, {\left ({\left (a^{7} + 3 \, a^{5} b^{2} + 3 \, a^{3} b^{4} + a b^{6}\right )} d \cos \left (d x + c\right ) + {\left (a^{6} b + 3 \, a^{4} b^{3} + 3 \, a^{2} b^{5} + b^{7}\right )} d \sin \left (d x + c\right )\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: AttributeError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.60, size = 250, normalized size = 1.64 \begin {gather*} \frac {\frac {8 \, a b^{4} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{6} b + 3 \, a^{4} b^{3} + 3 \, a^{2} b^{5} + b^{7}} - \frac {4 \, a b^{3} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{6} + 3 \, a^{4} b^{2} + 3 \, a^{2} b^{4} + b^{6}} + \frac {{\left (a^{4} + 6 \, a^{2} b^{2} - 3 \, b^{4}\right )} {\left (d x + c\right )}}{a^{6} + 3 \, a^{4} b^{2} + 3 \, a^{2} b^{4} + b^{6}} + \frac {a^{2} b \tan \left (d x + c\right )^{2} - 3 \, b^{3} \tan \left (d x + c\right )^{2} + a^{3} \tan \left (d x + c\right ) + a b^{2} \tan \left (d x + c\right ) + 2 \, a^{2} b - 2 \, b^{3}}{{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} {\left (b \tan \left (d x + c\right )^{3} + a \tan \left (d x + c\right )^{2} + b \tan \left (d x + c\right ) + a\right )}}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 3.93, size = 246, normalized size = 1.62 \begin {gather*} \frac {\frac {a^2\,b-b^3}{{\left (a^2+b^2\right )}^2}+\frac {{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (a^2\,b-3\,b^3\right )}{2\,\left (a^4+2\,a^2\,b^2+b^4\right )}+\frac {a\,\mathrm {tan}\left (c+d\,x\right )}{2\,\left (a^2+b^2\right )}}{d\,\left (b\,{\mathrm {tan}\left (c+d\,x\right )}^3+a\,{\mathrm {tan}\left (c+d\,x\right )}^2+b\,\mathrm {tan}\left (c+d\,x\right )+a\right )}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (-3\,b+a\,1{}\mathrm {i}\right )}{4\,d\,\left (-a^3-a^2\,b\,3{}\mathrm {i}+3\,a\,b^2+b^3\,1{}\mathrm {i}\right )}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (a-b\,3{}\mathrm {i}\right )}{4\,d\,\left (-a^3\,1{}\mathrm {i}-3\,a^2\,b+a\,b^2\,3{}\mathrm {i}+b^3\right )}+\frac {4\,a\,b^3\,\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}{d\,{\left (a^2+b^2\right )}^3} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________